var uid = "";
var _userinfo = null;
$(function() {
	uid = App.getTempData();
	App.getSendToUsers("user_" + uid, function(data) {
		var userInfo = "";
		userInfo += data.userName + "<br />";
		userInfo += data.deptName + "<br />";
		userInfo += data.posiName + "<br />";
		userInfo += "电话：" + data.teleNum + "<br />";
		$(".namecard_userinfo").html(userInfo);
		$(".namecard_specialty").html(data.userSpecialty);

		var file = new air.File(air.File.applicationDirectory.resolvePath("app:/assets/images/photos/" + uid + ".jpg").nativePath);
		if(file.exists) {
			$(".namecard_photo").attr("src", "assets/images/photos/" + uid + ".jpg");
		}
		_userinfo = data;
		//检测关注
		if(App.CheckCare(uid)) {
			$("#btnCare").removeClass("btn");
			$("#btnCare").addClass("subbtn");
			$("#btnCare").val("取消关注");
		} else {
			$("#btnCare").removeClass("subbtn");
			$("#btnCare").addClass("btn");
			$("#btnCare").val("添加关注");
		}
	}, function() {
		window.nativeWindow.close();
	});
	//寻呼
	$("#btnNetCall").bind("click", function() {
		window.nativeWindow.close();
		Const.msg._targetid = "user_" + uid;
		Common.OpenMsgWin();
	});
	//关注
	$("#btnCare").bind("click", function() {
		var val = $(this).val();
		if(val == "添加关注") {
			App.CareUser(_userinfo);
			$("#btnCare").removeClass("btn");
			$("#btnCare").addClass("subbtn");
			$("#btnCare").val("取消关注");
			$(this).css({
				"background" : "-webkit-gradient(linear, 0 0, 0 100% , from(#F6F8F9), to(#DADADE))"
			});
		} else {
			App.CareUser(_userinfo);
			$("#btnCare").removeClass("subbtn");
			$("#btnCare").addClass("btn");
			$("#btnCare").val("添加关注");
			$(this).css({
				"background" : "-webkit-gradient(linear, 0 0, 0 100% , from(#93E78B), to(#59B22E))"
			});
		}

	});
	//失去焦点时关闭窗口
	window.nativeWindow.addEventListener(air.Event.DEACTIVATE, function() {
		window.nativeWindow.close();
	});
});
